<?php
    ob_start();
    session_start();
    include "inc/config.php";
    $girisHata = false;
    if(isset($_POST))
    {
        if(isset($_POST['username']) AND isset($_POST['password']))
        {
            $UserSQL = $db->sql(" SELECT * FROM snm_users WHERE user_name = '". $db->escape($_POST['username']) ."' ");
            if($db->say($UserSQL) == 1)
            {
                $User = $db->getir($UserSQL);
                if(md5($_POST['password']) == $User['password'])
                {                                                                                                                  
                    $_SESSION['id'] = $User['id'];                                                                  
                    $_SESSION['user_name'] = $User['user_name'];
                    $_SESSION['constituent'] = $User['constituent'];
                    header('Location:index.php');
                }
                else
                {
                    $girisHata = true;
                }
            }
            else
            {
                $girisHata = true;
            }
        }
    }      
    
    include "template/login.php";                                
?>